package fr.umlv.android.boggle.model;

public class Letter {
	private final char letter;
	private final int row;
	private final int col;
	private boolean selected=false;
	
	Letter(char letter, int row, int col) {
		this.letter = letter;
		this.row = row;
		this.col = col;
	}
	
	public char getChar() {
		return letter;
	}
	
	public boolean isSelected() {
		return selected;
	}
	
	boolean select() {
		if(isSelected()) {
			return false;
		}
		selected = true;
		return true;
	}

	public boolean unselect() {
		if(!isSelected()) {
			return false;
		}
		selected = false;
		return true;
	}
	
	@Override
	public boolean equals(Object o) {
		if(!(o instanceof Letter)) {
			return false;
		}
		Letter letter = (Letter) o;
		return letter.getCol()==col && letter.getRow()==row  && letter.getChar()==this.getChar();
	}

	public int getRow() {
		return row;
	}

	public int getCol() {
		return col;
	}
}
